<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import axios from "axios";
import { getPublicKey } from "@/api/user";
export default {
  mounted() {
    this.getPublicKey();
    this.getVersion();
    setInterval(() => {
      this.getVersion();
    }, 5000);
  },
  methods: {
    async getPublicKey() {
      if (!this.$storage.getPublicKey()) {
        let res = await getPublicKey();
        if (res.code == 200) {
          this.$storage.setPublicKey(res.data);
        }
      }
    },
    getVersion() {
      let url = `//${window.location.host}/version.json`;
      if (process.env.NODE_ENV === 'production') {
        axios.get(url).then((res) => {
          let lastVersion = res.data.version;
          if (localStorage.version == undefined) {
            localStorage.setItem('version', lastVersion);
          } else {
            if (localStorage.version != lastVersion) {
              localStorage.removeItem('version');
              this.$Modal.confirm({
                  title:'提示',
                  content: "<p>检测到版本更新，刷新页面</p>",
                  onOk: () => {
                   window.location.reload();
                  },
                });
            }
          }
        });
      }
    }
  },
};
</script>

<style lang="scss">
.passport-area {
  width: 100%;
  margin: 0 auto;
  min-width: 1200px;
  min-height: 723px;
  @include bg-setting("login-bg", cover, center);
}
.box-area {
  background-color: #fff;
  border-radius: 10px;
  @include b-sh;
}
.font-bottom {
  @include h-c(null, null, #3d3d3d, #f9521f);
  cursor: pointer;
}
.font-b-bottom {
  @include h-c(null, null, #169bd5, rgba(#169bd5, 0.7));
  cursor: pointer;
}
</style>
